Modification start date
[BattleCats.git] / Assets / EZ Camera Shake / Demo / ShakeDemo.cs
blobd68851bcfd3c88e9d1a1cb97e0e3cfa9fae291cd
1 using UnityEngine;
2 using EZCameraShake;
4 public class ShakeDemo : MonoBehaviour
6 Vector3 posInf = new Vector3(0.25f, 0.25f, 0.25f);
7 Vector3 rotInf = new Vector3(1, 1, 1);
8 float magn = 1, rough = 1, fadeIn = 0.1f, fadeOut = 2f;
10 bool modValues;
11 bool showList;
13 CameraShakeInstance shake;
15 delegate float Slider(float val, string prefix, float min, float max, int pad);
17 void OnGUI()
19 if (Input.GetKeyDown(KeyCode.R))
21 Application.LoadLevel(Application.loadedLevel);
24 Slider s = delegate(float val, string prefix, float min, float max, int pad)
26 GUILayout.BeginHorizontal();
27 GUILayout.Label(prefix, GUILayout.MaxWidth(pad));
28 val = GUILayout.HorizontalSlider(val, min, max);
29 GUILayout.Label(val.ToString("F2"), GUILayout.MaxWidth(50));
30 GUILayout.EndHorizontal();
31 return val;
34 GUI.Box(new Rect(10, 10, 250, Screen.height - 15), "Make-A-Shake");
35 GUILayout.BeginArea(new Rect(29f, 40, 215, Screen.height - 40));
37 GUILayout.Label("--Position Infleunce--");
38 posInf.x = s(posInf.x, "X", 0, 4, 25);
39 posInf.y = s(posInf.y, "Y", 0, 4, 25);
40 posInf.z = s(posInf.z, "Z", 0, 4, 25);
42 GUILayout.Label("--Rotation Infleunce--");
43 rotInf.x = s(rotInf.x, "X", 0, 4, 25);
44 rotInf.y = s(rotInf.y, "Y", 0, 4, 25);
45 rotInf.z = s(rotInf.z, "Z", 0, 4, 25);
47 GUILayout.Label("--Other Properties--");
49 magn = s(magn, "Magnitude:", 0, 10, 75);
50 rough = s(rough, "Roughness:", 0, 20, 75);
52 fadeIn = s(fadeIn, "Fade In:", 0, 10, 75);
53 fadeOut = s(fadeOut, "Fade Out:", 0, 10, 75);
55 GUILayout.Label("--Saved Shake Instance--");
56 GUILayout.Label("You can save shake instances and modify their properties at runtime.");
58 if (shake == null && GUILayout.Button("Create Shake Instance"))
60 shake = CameraShaker.Instance.StartShake(magn, rough, fadeIn);
61 shake.DeleteOnInactive = false;
64 if (shake != null)
66 if (GUILayout.Button("Delete Shake Instance"))
68 shake.DeleteOnInactive = true;
69 shake.StartFadeOut(fadeOut);
70 shake = null;
74 if (shake != null)
76 GUILayout.BeginHorizontal();
77 if (GUILayout.Button("Fade Out"))
79 shake.StartFadeOut(fadeOut);
81 if (GUILayout.Button("Fade In"))
83 shake.StartFadeIn(fadeIn);
85 GUILayout.EndHorizontal();
87 modValues = GUILayout.Toggle(modValues, "Modify Instance Values");
89 if (modValues)
91 shake.ScaleMagnitude = magn;
92 shake.ScaleRoughness = rough;
93 shake.PositionInfluence = posInf;
94 shake.RotationInfluence = rotInf;
99 GUILayout.Label("--Shake Once--");
100 GUILayout.Label("You can simply have a shake that automatically starts and stops too.");
102 if (GUILayout.Button("Shake!"))
104 CameraShakeInstance c = CameraShaker.Instance.ShakeOnce(magn, rough, fadeIn, fadeOut);
105 c.PositionInfluence = posInf;
106 c.RotationInfluence = rotInf;
109 GUILayout.EndArea();
111 float height;
113 if (!showList)
114 height = 120;
115 else
116 height = 120 + CameraShaker.Instance.ShakeInstances.Count * 130f;
118 GUI.Box(new Rect(Screen.width - 310, 10, 300, height), "Shake Instance List");
119 GUILayout.BeginArea(new Rect(Screen.width - 285, 40, 255, Screen.height - 40));
121 GUILayout.Label("All shake instances are saved and stacked as long as they are active.");
123 showList = GUILayout.Toggle(showList, "Show List");
125 if (showList)
127 int index = 1;
128 foreach (CameraShakeInstance c in CameraShaker.Instance.ShakeInstances)
130 string state = c.CurrentState.ToString();
132 GUILayout.Label("#" + index + ": Magnitude: " + c.Magnitude.ToString("F2") + ", Roughness: " + c.Roughness.ToString("F2"));
133 GUILayout.Label(" Position Influence: " + c.PositionInfluence);
134 GUILayout.Label(" Rotation Influence: " + c.RotationInfluence);
135 GUILayout.Label(" State: " + state);
136 GUILayout.Label("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
137 index++;
140 GUILayout.EndArea();